//
//  CellManager.m
//  DaJiang
//
//  Created by sally on 16/10/7.
//  Copyright © 2016年 jiniu. All rights reserved.
//

#import "CellManager.h"

@implementation CellManager

// 配置UITableCell的正文本
+ (void)configCellText:(UITableViewCell *)cell type:(TextColorType)type {
  //排除：两处非常规字体（我的管理页、我的心愿、专家详情的预约话题列表）
  cell.textLabel.font = GCustomNormalFont; //13
  if (type == TextColorType_Gray) {
    cell.textLabel.textColor = GGrayWordColor1; //10
  } else {
    cell.textLabel.textColor = GBlackColor; //3
  }
}

// 配置UITableCell的正文本（常规的）
+ (void)configCellNormalText:(UITableViewCell *)cell {
  [self configCellText:cell type:TextColorType_Gray];
}

// 配置UITableCell的正文本（标题类）
+ (void)configCellTitleText:(UITableViewCell *)cell {
  cell.textLabel.font = GFontWithSize(GMiddleFontSize);
  cell.textLabel.textColor = GGrayWordColor1;
}

// 配置UITableCell的副文本
+ (void)configCellDetailText:(UITableViewCell *)cell {
  //排除：一处非常规字体（我的心愿）
  //cell.detailTextLabel.text = @"副标题";
  cell.detailTextLabel.font = GCustomNormalFont;
  cell.detailTextLabel.textColor = GBlackColor;
}

// 配置UITableCell的编辑行
+ (UITextField *)configCellTextField:(UITableViewCell *)cell type:(TextFieldType)type {
  //tip: tag、delegate、placeholder在页面中配置

  UITextField *textField;
  if (type == TextFieldType_Normal) { //常规的
    textField = [[UITextField alloc] initWithFrame:CGRectMake(95, 7, ScreenWidth - 95 - GNormalMargin, GSmallViewHeight)];
    textField.textAlignment = NSTextAlignmentRight;
  } else { //长的
    textField = [[UITextField alloc] initWithFrame:CGRectMake(GNormalMargin, 7, ScreenWidth - GNormalMargin * 2, GSmallViewHeight)];
    textField.textAlignment = NSTextAlignmentLeft;
  }

  textField.font = GCustomNormalFont;
  textField.textColor = GBlackColor;
  return textField;
}

// 配置UITableCell的编辑行（常规的）
+ (UITextField *)configCellNormalTextField:(UITableViewCell *)cell {
  return [self configCellTextField:cell type:TextFieldType_Normal];
}

// 配置UITableCell的编辑框
+ (UITextView *)configCellTextView:(UITableViewCell *)cell {
  //tip: placeholder在页面中配置

  UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(GSmallMargin, 0, ScreenWidth - GNormalMargin * 2, GTextViewHeight - NavHeight)];
  textView.font = GCustomNormalFont;
  textView.textColor = GBlackColor;
  return textView;
}

// 配置UITableCell的打分控件
+ (CWStarRateView *)configCellStarRateView:(BOOL)isSelect{
  CWStarRateView *starRateView = [[CWStarRateView alloc] initWithFrame:CGRectMake(ScreenWidth - 140, 12, 125, 20) numberOfStars:5];
  starRateView.scorePercent = 1;
  starRateView.allowIncompleteStar = NO;
  starRateView.hasAnimation = YES;
  if (isSelect) {
    starRateView.userInteractionEnabled = YES;
  } else {
    starRateView.userInteractionEnabled = NO;
  }

  return starRateView;
}

// 配置UITableCell的选择按钮（用户是否出现-预约）
+ (UIButton *)configCellAppearBtn{
  UIButton *noAppearBtn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth - GNormalMargin - NavHeight, 0, NavHeight, NavHeight)];
  [noAppearBtn setImage:[UIImage imageNamed:@"notebook_unread_ic"] forState:UIControlStateNormal];
  [noAppearBtn setImage:[UIImage imageNamed:@"notebook_read_ic"] forState:UIControlStateSelected];
  noAppearBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  return noAppearBtn;
}

@end
